//
//  RootTabBarViewController.m
//  XiangMuB
//
//  Created by 999999999999 on 16/8/12.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "RootTabBarViewController.h"
#import "NewViewController.h"
#import "SettingViewController.h"
#import "AttentionViewController.h"
#import "MessageViewController.h"
#import "navigationController.h"
@interface RootTabBarViewController ()

@end

@implementation RootTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //夜间模式
    [self.tabBar NightWithType:UIViewColorTypeNormal];
    
   
    
    //tabbar
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    dic[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    dic[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    NSMutableDictionary *selectDic = [NSMutableDictionary dictionary];
    selectDic[NSFontAttributeName] = dic[NSFontAttributeName];
    selectDic[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    //全部显示,不用每个设置,  appearance
    UITabBarItem *item= [UITabBarItem appearance];
    [item setTitleTextAttributes:dic forState:(UIControlStateNormal)];
    [item setTitleTextAttributes:selectDic forState:(UIControlStateSelected)];
    
    
    //添加子控制器
    [self setupChildVC:[[NewViewController alloc] init] title:@"新闻" image:@"tabBar_essence_icon" selectedImage:@"tabBar_essence_click_icon"];
    
    [self setupChildVC:[[AttentionViewController alloc] init] title: @"关注" image:@"tabBar_friendTrends_icon" selectedImage:@"tabBar_friendTrends_click_icon"];
    [self setupChildVC:[[MessageViewController alloc] init] title: @"新帖" image:@"tabBar_new_icon" selectedImage:@"tabBar_new_click_icon"];
   
    
    [self setupChildVC:[[SettingViewController alloc] init] title:@"设置" image: @"tabBar_me_icon"selectedImage:@"tabBar_me_click_icon"];
    
}
//初始化子控制器
//(Class)class::::需要使用的控制器

-(void)setupChildVC:(UIViewController *)vc title:(NSString *)title  image:(NSString *)image selectedImage:(NSString *)selectedImage{
    //设置图片文字
    vc.tabBarItem.title = title;
    //    vc.navigationItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:image];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
    
    //添加导航控制器,添加子视图
    
    navigationController *nav = [[navigationController alloc]initWithRootViewController:vc];
    
    
     
//    [nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationbarBackgroundWhite"] forBarMetrics:(UIBarMetricsDefault)];
    [self addChildViewController:nav];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
